package com.sixth.controller;
import com.sixth.entity.Head;
import com.sixth.entity.TableResult;
import com.sixth.service.HeadNavigationService;
import com.sixth.until.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: self-tui-education
 * @description:
 * @author: C
 * @create: 2022-04-16 00:14
 **/
@RestController
@RequestMapping("/home/head")
public class HeadNavigationController {
    @Autowired
    private HeadNavigationService headNavigationService;

    //头部导航删除功能
    @PostMapping("/deleteHeadNav")
    public CommonResult delete(@RequestBody Head head ) {
        return headNavigationService.deleteFindById(head);
    }

    //头部导航查询功能
    @PostMapping("/getAllHeadNav/{currentPage}/{pageSize}")
    private TableResult selectAllTeacher(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody Head head) {
        return headNavigationService.selectAllHead(currentPage, pageSize, head);
    }

    @PostMapping("/addHeadNav")
    public CommonResult addHeadNav(@RequestBody Head head) {
        if (head.getHeadId() == null) {
            return headNavigationService.addHead(head);
        } else {
            return headNavigationService.UpdateHead(head);
        }
    }

    //头部导航修改状态
    @PostMapping("changeStatus/{headId}/{isDiable}")
    public CommonResult changeStatus(@PathVariable Integer headId, @PathVariable String isDiable) {
        return headNavigationService.changeStatus(headId, isDiable);
    }
}


